<%--
  Created by IntelliJ IDEA.
  User: 范军建
  Date: 2022/4/15
  Time: 14:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    String path =request.getContextPath();
%>
<script src="js/jquery-1.12.4.min.js"></script>
<script type="text/javascript">

    function login(){
        var name = $("#username").val();
        var pass = $("#passwd").val();
        alert(name)
        $.ajax({
            url:"deng",
            type:"get",
            data:{
                username:name,
                password:pass
            },
            dataType:"text",

            success:function (data) {
                alert(data)

                if (data==1){
                    var path=document.getElementById("path").value;
                    window.location.href=path+"/index2.jsp"
                }

            },
            error:function (data) {
                if (data==0){
                    alert("查询失败")
                }

            }
        })
    }

</script>
<!-- 一个简单的表单结构 -->
<form class="login" action="#" method="get">
    <label>用户名：</label>
    <input id="username" type="text" value="">
    <label>密  码：</label>
    <input id="passwd" type="text"  value="">
    <input type="hidden" id="path" value="<%=path%> "style="margin-left: 60px">
</form>
<button onclick="login()">登录</button>

</body>
</html>
